package com.acwing.partition3;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/2/12 17:18
 */
public class AC241楼兰图腾 {

    private static final int N = 200010;
    private static int[] a = new int[N], c = new int[N], greater = new int[N], lower = new int[N];
    private static int n = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = Integer.parseInt(reader.readLine());
        String[] ss = reader.readLine().split(" ");
        for (int i = 1; i <= n; i++) a[i] = Integer.parseInt(ss[i - 1]);
        //从左向右遍历，依次统计左边比当前数大的数和小的数
        for (int i = 1; i <= n; i++) {
            int x = a[i];
            //分别统计区间[1, x - 1]和[x + 1, n]中数字出现的次数
            lower[i] = ask(x - 1);
            greater[i] = ask(n) - ask(x);
            add(x, 1);
        }
        for (int i = 1; i <= n; i++) c[i] = 0;
        //从右向左遍历，依次统计右边比当前数大的数和小的数，并在统计的过程中计算结果
        long ans1 = 0, ans2 = 0;
        for (int i = n; i >= 1; i--) {
            int x = a[i];
            ans1 += (long) greater[i] * (ask(n) - ask(x));
            ans2 += (long) lower[i] * ask(x - 1);
            add(x, 1);
        }
        writer.write(ans1 + " " + ans2 + "\n");
        writer.flush();
    }

    private static int ask(int x) {
        int res = 0;
        for (int i = x; i != 0; i -= lowbit(i)) res += c[i];
        return res;
    }

    private static void add(int x, int k) {
        for (int i = x; i <= n; i += lowbit(i)) c[i] += k;
    }

    private static int lowbit(int x) {
        return x & -x;
    }
}
